package com.example.stock.controller;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

@Controller
public class MessageController {

    // 处理客户端发送到 /app/chat 的消息
    @MessageMapping("/chat")
    @SendTo("/topic/messages") // 广播到所有订阅 /topic/messages 的客户端
    public String handleMessage(String message) {
        System.out.println(message);
        return "Server: " + message;
    }
}